1 #include <iostream>
2 #include <iomanip>
3 #include <conio.h>
4 #include <string.h>
5 #include <windows.h>
6 #include "sinlist.h"
7 #define WINWIDTH 113
8 #define WINHEIGHT 15
9 using namespace std;
10
11 void filler();
12 void liner();
13 void welcome();
14 void exitscreen();
15
16 char pname[30]; //Product name
17 int pid; //Product id
18 int price; //Product price
19 int tquant; //Total products purchased from wholesale
20 int aquant; //How many are available in stock
21 int rack;
22
23 char filename[50];
24
25 class store
26 {
27 LinkedList obj;
28 int t;
29 public:
30 store()
31 {
32 t = 0;
33 obj.ReadFromFile(obj);
34 }
35 void add()
36 {
37 system("CLS");
38 cout<<"\n\t\t\t[press enter after each details]";
39 cout << "\nEnter Product name" << endl;
40 cin >> pname;
41
42 cout << "\nEnter Product id" << endl;
43 cin >> pid;
44
45 cout << "\nEnter Price" << endl;
46 cin >> price;
47
48 cout << "\nEnter Total Qty" << endl;
49 cin >> tquant;
50
51 cout << "\nEnter Available Qty" << endl;
52 cin >> aquant;
53
54 cout << "\nEnter Rack No" << endl;
55 cin >> rack;
56
57 //cout << "\nEnter Product name, Product id, Price, Total Qty, Available Qty, Rack No" << endl;
58 //cin >> pname >> pid >> price >> tquant >> aquant >> rack;
59
60 obj.add_end(pname,pid,price,tquant,aquant,rack);
61 }
62 void display()
63 {
64 obj.display();
65 }
66 int getrecs()
67 {
68 return obj.recsnum();
69 }
70 void modify()
71 {
72 obj.modify();
73 }
74 void PrintBill();
75 void deleteproduct()
76 {
77 system("CLS");
78 char name[30];
79 cout << "\n\nEnter name of product : ";
80 cin >> name;
81 obj.delete_node(name);
82 }
83 void SearchProduct()
84 {
85 obj.Search();
86 }
87 void totalprinter();
88 ~store()
89 {
90 cout << "Number of records = " << obj.getcount() << endl;
91 obj.SaveToFile();
92 exitscreen();
93 }
94 };
95
96 void store::PrintBill()
97 {
98 system("CLS");
99 int choice;
100 char sname[] = {"Product Name"};
101 char name[30];
102 int quantity;
103 cout << "\n\nEnter filename for bill with full path and file extension : ";
104 cin >> filename;
105 FILE *fp;
106 fp = fopen(filename,"a");
107 for(int i = 0 ; i < 70 ; i++)
108 {
109 fprintf(fp,"*");
110 }
111 fprintf(fp,"\n");
112 //brought to you by code-projects.org
113 fprintf(fp,"%-30s\tQty.\tPrice/item\tAmount\n",sname);
114
115 for(int i = 0 ; i < 70 ; i++)
116 {
117 fprintf(fp,"*");
118 }
119 fprintf(fp,"\n");
120 fclose(fp);
121 while(1)
122 {
123 cout << "\nContinue Purchasing Product ?\n1 = yes , 2 = no" << endl;
124 cout << "choice : ";
125 cin >> choice;
126 if(choice == 1)
127 {
128 cout << "\nEnter product name and quantity : " << endl;
129 cin >> name >> quantity;
130 obj.billgen(filename,name,quantity,t);
131 }
132 else
133 break;
134 }
135 fp = fopen(filename,"app");
136 }
137
138 void store::totalprinter()
139 {
140 FILE *fp;
141 fp = fopen(filename,"a");
142 fprintf(fp,"\n");
143 for(int i = 0 ; i < 70 ; i++)
144 {
145 fprintf(fp,"*");
146 }
147
148
149 fprintf(fp,"\n");
150
151 for(int i = 0 ; i < 70 ; i++)
152 {
153 fprintf(fp,"*");
154 }
155 fprintf(fp,"\n");
156 fprintf(fp,"Total = %d\n",t);
157 for(int i = 0 ; i < 70 ; i++)
158 {
159 fprintf(fp,"*");
160 }
161 fprintf(fp,"\n");
162 fclose(fp);
163 }
164 int main()
165 {
166 store obj;
167 int ch;
168 welcome();
169 cout << endl << "Press any key to continue" << endl;
170 getch();
171 while(1)
172 {
173 system("CLS");
174 cout <<"\n\n\t\t\t---------------------------------------------";
175 cout << "\n\t\t\tSIMPLE ELECTRONIC STORE MANAGEMENT SYSTEM : \n\t\t\t---------------------------------------------" << endl
176 << "\n\t\t\t\t (1) To Add Products" << endl
177 << "\t\t\t\t (2) To Display Products" << endl
178 << "\t\t\t\t (3) To Modify Products" << endl
179 << "\t\t\t\t (4) To Delete Products" << endl
180 << "\t\t\t\t (5) To Search Products" << endl
181 << "\t\t\t\t (6) To Sell Products" << endl
182 << "\t\t\t\t (7) Exit " << endl;
183 cout << "\t\t\t Choice : ";
184 cin >> ch;
185 switch(ch)
186 {
187 case 1 : obj.add();
188 break;
189 case 2 : obj.display();
190 getch();
191 break;
192 case 3 : obj.modify();
193 break;
194 case 4 : obj.deleteproduct();
195 getch();
196 break;
197 case 5 : obj.SearchProduct();
198 break;
199 case 6 : obj.PrintBill();
200 obj.totalprinter();
201 getch();
202
203 break;
204 case 7 : return 0;
205 }
206 }
207 return 0;
208 }
209
210 void filler()
211 {
212 for(int i = 0 ; i < WINWIDTH ; i++)
213 {
214 cout << "*";
215 }
216 cout << "\a" << endl;
217 }
218
219 void liner()
220 {
221 for(int i = 0 ; i < WINHEIGHT ; i++)
222 cout << endl;
223 }
224
225 void welcome()
226 {
227 liner();
228 cout << "Loading..." << endl;
229 Sleep(500);
230 char msg[] = "WELCOME TO ELECTRONIC STORE MANAGEMENT SYSTEM";
231 int len = strlen(msg);
232 int x;
233 x = (WINWIDTH/2) - (len/2);
234 for(int i = 0 ; i < WINWIDTH ; i++)
235 {
236 printf("%c",177);
237 Sleep(55);
238 }
239 cout << endl;
240 system("CLS");
241 liner();
242 filler();
243 cout << setw(len+x) << msg << endl;
244 filler();
245 }
246
247 void exitscreen()
248 {
249 system("CLS");
250 char msg[] = "Brought To You By code-projects.org";
251 int len = strlen(msg);
252 int x;
253 x = (WINWIDTH/2) - (len/2);
254 liner();
255 filler();
256 cout << setw(len+x) << msg << endl;
257 filler();
258 }